package com.edu.exam.entity.curriculum.academic;

import com.edu.exam.entity.curriculum.academic.enums.MajorStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 专业实体类
 * 所属模块：F-02 专业培养层次管理模块
 * 对应数据库表：majors
 *
 * 根据F-02专业培养层次管理模块设计文档实现
 * 管理专业的基本信息，包括专业代码、名称、所属院系、状态等。
 * 支持专业的创建、查询、更新和状态管理。
 *
 * @author System
 * @version 2.0.0
 */
@Entity
@Table(name = "majors")
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Major {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @NotBlank(message = "专业代码不能为空")
    @Size(max = 20, message = "专业代码长度不能超过20个字符")
    @Column(name = "code", nullable = false, length = 20, unique = true)
    private String code;

    @NotBlank(message = "专业名称不能为空")
    @Size(max = 100, message = "专业名称长度不能超过100个字符")
    @Column(name = "name", nullable = false, length = 100, unique = true)
    private String name;

    @Size(max = 200, message = "专业英文名称长度不能超过200个字符")
    @Column(name = "english_name", length = 200)
    private String englishName;

    @NotNull(message = "所属院系ID不能为空")
    @Column(name = "department_id", nullable = false)
    private Long departmentId;

    @NotNull(message = "专业状态不能为空")
    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false, length = 20)
    private MajorStatus status;

    @NotNull(message = "显示顺序不能为空")
    @Column(name = "display_order", nullable = false)
    private Integer displayOrder;

    @Column(name = "description", columnDefinition = "TEXT")
    private String description;

    @Size(max = 50, message = "创建人长度不能超过50个字符")
    @Column(name = "created_by", nullable = false, length = 50)
    private String createdBy;

    @CreatedDate
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    @Size(max = 50, message = "更新人长度不能超过50个字符")
    @Column(name = "updated_by", nullable = false, length = 50)
    private String updatedBy;

    @LastModifiedDate
    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

}